<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>DISPROJU</title>
		<link rel="icon" href="<?php echo base_url('includes/images/disproju.png'); ?>" type="image/png">
		<!-- Bootstrap core CSS -->
</head>
	<body>		
	<div class="container">
        <div class="row">
        	<center><h2>DISPROJU</h2></center>
            <div class="col-lg-6 col-lg-offset-3">
                <div class="well bs-component">
			<form class="form-horizontal" id="form" name="form">
                        <fieldset>
                            <center><img src="http://www.arapongas.pr.gov.br/imagens/arapongas.png" width="100" border="0" alt="" /></center> <br>
                          <div class="form-group">
                            <label class="col-lg-2 control-label">Usu&aacute;rio</label>
                            <div class="col-lg-10">
                              <input type="text" class="form-control" name="userLogin" id="userLogin" placeholder="Nome do usu&aacute;rio" tabindex="1" required>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="col-lg-2 control-label">Senha</label>
                            <div class="col-lg-10">
                                <input type="password" class="form-control" name="userPassword" id="userPassword" placeholder="Senha" tabindex="2" required>
                            </div>
                          </div>

                        <div class="form-group">
                          <div class="col-lg-10 col-lg-offset-2">
                              <button type="submit" class="btn btn-primary">Entrar</button>
                          </div>
                        </div>
                        </fieldset>
                     </form>
					<div id="out" style="margin:5px 0px 0px 10px;heigth:50px;text-align:center;">
					<a href="http://intranet.arapongas.pr.gov.br">Voltar</a>
					</div>
					<div id="info"></div>
                </div>
            </div>
			
		</div>
		<p style="text-align: center; font-size: 12px;">© 2013-<?php echo date('Y');?> - Desenvolvido pela Diretoria de Tecnologia da Informação - DTI </p>
	</div>

<script type="text/javascript" src="<?php echo base_url('includes/js/jquery-1.11.1.min.js')?>"></script>
<script type="text/javascript" src="<?php echo base_url('includes/js/jquery.validate.min.js')?>"></script>
<script src="<?php echo base_url('includes/bootstrap/js/bootstrap.min.js') ?>"></script>
<link href="<?php echo base_url('includes/bootstrap/css/bootstrap.min.css') ?>" rel="stylesheet">
<script language="javascript">
$().ready(function() {
	// validate signup form on keyup and submit
	$('#userLogin').focus();
	$("#form").validate({
		rules: {
			userLogin: "required",
			userPassword: { 
                            required: true,
                            minlength: 5,
                        },
		},
		highlight: function(element) {
			$(element).closest('.form-group').addClass('has-error alert alert-block alert-error fade in');
		},
		unhighlight: function(element) {
			$(element).closest('.form-group').removeClass('has-error alert alert-block alert-error fade in');
		},
		errorElement: 'span',
		errorClass: 'help-block',
		errorPlacement: function(error, element) {
			if(element.parent('.input-group').length) {
				error.insertAfter(element.parent());
			} else {
				error.insertAfter(element);
			}
		},
		messages: {
			userLogin: "Por favor, preencha este campo",
			userPassword: {
				required: "Por favor, preencha este campo",
				minlength: "Mínimo 5 caracteres requeridos",
				equalTo: "Confirmação de Senha e Senha devem ser iguais"
			},
		}, 
		submitHandler: function(form){
			var dados = $('#form').serialize();
			$.ajax({
					type: "POST",
					url: "<?php echo base_url('index.php/login');?>",
					data: dados,
					success: function( data )
					{
						if(data == 'success'){
							window.location.href = "<?php echo base_url('index.php/inicio');?>";
						}else{
							$("#info").html(data);
							setTimeout(function() {
								$('#info').html('');
								$('#userLogin').focus();
								$('#userPassword').val('');
							}, 3000);
						}
					}
			});
			return false;
		}
	});
        

});

    </script>
</body>
</html>
